package health_system.health_system.dto;

import health_system.health_system.entity.MomentLike;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class MomentLikeDTO {
    private Long id;
    private Long momentId;
    private String momentContent;
    private Long userId;
    private String username;
    private String userAvatarUrl;
    private LocalDateTime createdAt;
    
    public static MomentLikeDTO fromEntity(MomentLike like) {
        if (like == null) {
            return null;
        }
        
        MomentLikeDTO dto = new MomentLikeDTO();
        dto.setId(like.getId());
        
        if (like.getMoment() != null) {
            dto.setMomentId(like.getMoment().getId());
            dto.setMomentContent(like.getMoment().getContent());
        }
        
        if (like.getUser() != null) {
            dto.setUserId(like.getUser().getId());
            dto.setUsername(like.getUser().getUsername());
            dto.setUserAvatarUrl(like.getUser().getAvatarUrl());
        }
        
        dto.setCreatedAt(like.getCreatedAt());
        
        return dto;
    }
} 